package com.pro.controller;/*
    @description: TDD
    @author: 赵自强
    @date: 2022/1/20 18:43
*/

import com.pro.pojo.JsCarousel;
import com.pro.pojo.JsonData;
import com.pro.service.AdvertisementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/advertisement")
public class AdvertisementController {

    @Autowired
    private AdvertisementService advertisementService;

    /*
     * create by: 赵自强
     * create time: 2022/1/20 18:46
     * @return com.pro.pojo.JsonData
     * 获取轮播图列表||检索 getRotationCharts JsCarousel jsCarousel
     */
    @RequestMapping("/getRotationCharts")
    public JsonData getRotationCharts(JsCarousel jsCarousel){
        List<JsCarousel> rotationCharts = advertisementService.getRotationCharts(jsCarousel);
        return rotationCharts!=null? JsonData.buildSuccess(rotationCharts):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/20 19:22
     * @return com.pro.pojo.JsonData
     * 删除轮播图 delRotationChart Integer carouselId
     */
    @RequestMapping("/delRotationChart")
    public JsonData delRotationChart(Integer carouselId){
        Boolean delRotationChart = advertisementService.delRotationChart(carouselId);
        return delRotationChart? JsonData.buildSuccess(delRotationChart):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/21 19:24
     * @return com.pro.pojo.JsonData
     * 编辑轮播图 editRotationChart JsCarousel jsCarousel
     */
    @RequestMapping("/editRotationChart")
    public JsonData editRotationChart(JsCarousel jsCarousel){
        Boolean editRotationChart = advertisementService.editRotationChart(jsCarousel);
        return editRotationChart? JsonData.buildSuccess(editRotationChart):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/21 20:43
     * @return com.pro.pojo.JsonData
     * 添加轮播图 addAdvertisement JsCarousel jsCarousel
     */
    @RequestMapping("/addAdvertisement")
    public JsonData addAdvertisement(JsCarousel jsCarousel){
        Boolean addAdvertisement = advertisementService.addAdvertisement(jsCarousel);
        return addAdvertisement? JsonData.buildSuccess(addAdvertisement):JsonData.buildError("后台数据错误");
    }

}
